﻿import React, { Component} from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as elementAction from '../../actions/actions';
import $ from 'jquery';
import { Menu, Icon } from 'antd';
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
import TableTest from '../views/tableTest.js';
import * as weapon from '../../utils/weapon.js';
import classnames from 'classnames';

import {
  HashRouter as Router,
  Route,
  Link
} from 'react-router-dom'

class CsMenu extends Component {
	constructor(props) {
		super(props);
	}
	componentWillReceiveProps(nextProp){
	}
	componentDidMount(){
	}
	render() {
		const{dataSource,fields}=this.props
		console.log(dataSource);
		return (
			<ul className="menuRoot">
				{weapon.menuRender(dataSource,fields,(item)=>{
					if(item.isLeaf && item.level!=1){
						var path={path:item.url}
						return(
							<li key={item.id}>
								<router-link
									className="nodeLeaf"
									style={{paddingLeft:(parseInt(item.level)-1)*10+"px"}}
									to={path}>
									<s className="icon fa inner-dot-icon"></s><span className="label">{item.name}</span>
								</router-link>
							</li>
						)
					}else{
						<li
							key={item.id}
							className={classnames("branchNode","branchNode_L"+item.level,{branchNode_LevelMore:(item.level>1)},{"open":item.open})}>
							<div className="nodeSelf">
								<s className={["icon","fa",item.icon].join(" ")}></s>
								<span className="label">{item.name}</span>
								<div className={["fa","fa fa-chevron-left","state"].join(" ")}></div>
							</div>
							<ul className="subMenu"
								style={{display:"",height:"auto"}}
								ref={"subMenu_"+item.id}>
							</ul>
						</li>
					}
				})}
			</ul>
		)
	}
}
CsMenu.defaultProps={
	dataSource:[],
	fields:{
		id:"id",
		pId:"pId"
	}
}
export default CsMenu;
/*
				{weapon.menuRender(dataSource,fields,(item)=>{
					if(item.isLeaf && item.level!=1){
						var path={path:item.url}
						return(
							<li key={item.id}>
								<router-link
									className="nodeLeaf"
									style={{paddingLeft:(parseInt(item.level)-1)*10+"px"}}
									to={path}>
									<s className="icon fa inner-dot-icon"></s><span className="label">{item.name}</span>
								</router-link>
							</li>
						)
					}else{
						<li
							key={item.id}
							className={classnames("branchNode","branchNode_L"+item.level,{branchNode_LevelMore:(item.level>1)},{"open":item.open})}>
							<div className="nodeSelf">
								<s className={["icon","fa",item.icon].join(" ")}></s>
								<span className="label">{item.name}</span>
								<div className={["fa","fa fa-chevron-left","state"].join(" ")}></div>
							</div>
							<ul className="subMenu"
								style={{display:"",height:"auto"}}
								ref={"subMenu_"+item.id}>
							</ul>
						</li>
					}
				})}
*/
